{include file="public/header" /}
<style>
    .layui-flow-more a {
        display: block !important;
    }
</style>
<body class="bgc">
<div class="header flex-center">商城</div>

<div class="classify-content">
    <ul class="left">
        {foreach name="child" key="key" item="vo"}
        <li data-id="{$vo.id}" class="{if $key == 0}active{/if} switch">
            <span></span>
            <p>{$vo.title}</p>
        </li>
        {/foreach}
    </ul>
    <ul class="right tpl_list"></ul>
</div>

<script id="template" type="text/html">
    {{# for(var i = 0; i < d.data.length; i++){ }}
    <li>
        <a href="javascript:;">
            <p class="flex-center"  onclick="load_href('{:url(\'product/spec_details\')}?id={{d.data[i].id}}',2)">
                <img lay-src="{{d.data[i].icon}}" src="{{d.data[i].icon}}" alt="">
            </p>
            <div class="rgt">
                <p class="multi">{{d.data[i].title}}</p>
                <div class="flex-layout">
                    <div>
                        <p class="old-price">￥{{d.data[i].price}}</p>
                        <p class="price">￥<span>{{d.data[i].vip_price}}</span></p>
                    </div>
<!--                    <img data-id="{{d.data[i].id}}" class="addCart" src="/static/index/img/icon49.png" alt="">-->
                </div>
            </div>
        </a>
    </li>
    {{# } }}
</script>
{include file="public/menu" select="2" /}
</body>
{include file="public/footer"/}
<script>
    $(function () {
        var a = $, s = a('.switch'), t = a('.tpl_list'), v = 'active',
            api = {addCart: '{:url("cart/add")}'};

        getFlow(1, "{:url('product/getList')}?cate_1={$child?$child.0.id:''}");
        s.click(function () {
            t.empty();
            getFlow(1, "{:url('product/getList')}?cate_1=" + a(this).attr('data-id'));
            a(this).addClass(v).addClass(v).siblings().removeClass(v)
        })
        t.on('click','.addCart',function () {
            return common.request(api.addCart, {pid: a(this).attr('data-id'), num: 1, type: 1});
        });
    })
</script>
</html>